
public class FileTest {

	public void testFileConstructor(){
		// File has name and null parent
		File f1 = new File("f1", null);
		assert f1.getName()=="f1";
		assert f1.getParent()==null;
		
		// File has name and Directory parent
		Directory d2 = new Directory("d2", null);
		File f2 = new File("f2", d2);
		assert f2.getName()=="f2";
		assert f2.getParent()==d2;
		System.out.println("constructor works");
	}
	
	public void testFileContents(){
		// Ensure New File has empty contents;
		File f1 = new File("f1", null);
		assert f1.getContents().equals("");
		
		// Ensure contents changes as intended
		f1.setContents("intended contents");
		assert f1.getContents()=="intended contents";
		
		// Ensure contents can be appended
		f1.appendContents("next line of stuff");
		assert f1.getContents().equals(("intended contents"+"\n"+"next line of stuff"));
		
		// Ensure contents can be erased
		f1.eraseContents();
		assert f1.getContents()=="";
		
		// Append text to empty contents
		f1.appendContents("Appending to emptyfile");
		assert f1.getContents().equals("\nAppending to emptyfile");
		
		// Append empty string to empty contents
		f1.eraseContents();
		f1.appendContents("");
		assert f1.getContents().equals("\n");
		
		System.out.println("file contents modify as intended");
	}
	
	public static void main(String[] args){
		FileTest tester = new FileTest();
		tester.testFileConstructor();
		tester.testFileContents();
	}
}
